<extend name="./public/frame.html"/>
<block name="content">
    <style>
        .layui-form-label{width: 15%;}
        .layui-input-block{margin-left: 12%;}
    </style>
    <form class="layui-form layui-form-pane1" method="post" enctype="multipart/form-data">
        <div class="layui-form-item">
            <label class="layui-form-label">加盟商名称</label>
            <div class="layui-input-block"><input type="text" value="<?php echo $franchiseeInfo['franchisee_name'];?>" class="layui-input" style="width: 400px;border: 0px;" readonly></div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">推广员姓名</label>
            <div class="layui-input-block">
                <input type="text" name="name" lay-verify="required" placeholder="请输入推广员姓名"
                       autocomplete="off" class="layui-input" style="width: 400px;" value="<?php echo $referInfo['name'];?>">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">推广员手机号</label>
            <div class="layui-input-block">
                <input type="text" name="phone" lay-verify="required" placeholder="请输入推广员手机号"
                       autocomplete="off" class="layui-input" style="width: 400px;border: 0px;" value="<?php echo $referInfo['user_phone'];?>" disabled>
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-block">
                <input type="hidden" value="<?php echo $referInfo['id'];?>" name="id">
                <button class="layui-btn" lay-submit="" lay-filter="add">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
            </div>
        </div>
    </form>
    <script>
        layui.use(['form'], function () {
            form = layui.form;
            form.on('submit(add)', function(data){
                var name     = data.field.name;
                var phone    = data.field.phone;
                var id       = data.field.id;
                $.ajax({
                    url:'{:url("/admin/Refer/referUpdate")}',
                    async:true,
                    dataType:'json',
                    type:'POST',
                    data:{'name':name,'phone':phone,'id':id},
                    success:function(res){
                        if(res.code==1){
                            layer.alert(res.msg, {icon: 6},function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.parent.location.reload()
                            });
                        }else{
                            layer.msg(res.msg,{icon: 5});
                        }
                    }
                });
                return false;
            });
        });
    </script>
</block>
